package xian.woniu.util;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

@Repository
public class RedisTokenBean<K,V> implements TokenBean<K,V>{

    @Autowired
    private RedisTemplate redisTemplate;


    @Override
    public void put(K k, V v) {
        redisTemplate.opsForValue().set(k,v);
    }

    @Override
    public V get(K k) {
        return (V)redisTemplate.opsForValue().get(k);
    }

    @Override
    public void remove(K k) {
        redisTemplate.opsForValue().getAndSet(k,"");
    }
}